﻿Public Class NhaDAO
    Public Shared Function Nha_Load() As DataTable
        Return DataProvider.LoadTable("select * from NHA")
    End Function

    Public Shared Sub Nha_Insert(ByVal n As NhaDTO)
        Dim Npara As Integer = 7
        Dim sql As String = "usp_Nha_insertNha"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@MANHA"
        name(1) = "@MALOAINHA"
        name(2) = "@DIENTICH"
        name(3) = "@MUCGIA"
        name(4) = "@DIACHI"
        name(5) = "@TINHTRANG"
        name(6) = "@MADV"
        n.Manha = AutoInc.AutoIncStr(NhaDAO.Nha_Load, "MANHA", "N")
        n.Tinhtrang = 0
        value(0) = n.Manha
        value(1) = n.Maloainha
        value(2) = n.Dientich
        value(3) = n.Mucgia
        value(4) = n.Diachi
        value(5) = n.Tinhtrang
        value(6) = n.Madv
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub

    Public Shared Sub Nha_Update(ByVal n As NhaDTO)
        Dim Npara As Integer = 7
        Dim sql As String = "usp_Nha_updateNha"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@MANHA"
        name(1) = "@MALOAINHA"
        name(2) = "@DIENTICH"
        name(3) = "@MUCGIA"
        name(4) = "@DIACHI"
        name(5) = "@TINHTRANG"
        name(6) = "@MADV"
        value(0) = n.Manha
        value(1) = n.Maloainha
        value(2) = n.Dientich
        value(3) = n.Mucgia
        value(4) = n.Diachi
        value(5) = n.Tinhtrang
        value(6) = n.Madv
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub
    Public Shared Sub Nha_Delete(ByVal n As NhaDTO)
        Dim sql As String = String.Format("delete Nha where MANha = '{0}'", n.Manha)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
End Class
